package com.mall.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mall.dubbo.mapper.SmsFlashPromotionMapper;
import com.mall.model.domain.SmsFlashPromotion;
import org.apache.commons.lang.StringUtils;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author xyiaao
 * @description 针对表【sms_flash_promotion(限时购表)】的数据库操作Api实现
 * @createDate 2022-03-29 19:46:09
 */
@DubboService
public class SmsFlashPromotionApiImpl extends ServiceImpl<SmsFlashPromotionMapper, SmsFlashPromotion>
        implements SmsFlashPromotionApi {

    @Autowired
    private SmsFlashPromotionMapper smsFlashPromotionMapper;

    //根据活动名称分页查询
    public Page<SmsFlashPromotion> findList(String keyword, Integer pageNum, Integer pageSize) {

        Page<SmsFlashPromotion> page = new Page<>(pageNum, pageSize);

        LambdaQueryWrapper<SmsFlashPromotion> lqw = new LambdaQueryWrapper<>();
        lqw.like(StringUtils.isNotEmpty(keyword), SmsFlashPromotion::getTitle, keyword);

        return smsFlashPromotionMapper.selectPage(page, lqw);
    }

    //修改数据
    public void updateFlash(Integer id, SmsFlashPromotion smsFlashPromotion) {

        LambdaQueryWrapper<SmsFlashPromotion> lqw = new LambdaQueryWrapper<>();
        lqw.eq(id != null, SmsFlashPromotion::getId, Long.valueOf(id));

        smsFlashPromotionMapper.update(smsFlashPromotion, lqw);

    }

}




